#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
LL w[N];
bool st[N];
int n, cnt;
vector<int> edges[N];
void solve()
{
    cnt = 0;
    memset(st, 0, sizeof st);
    for(int i = 1; i <= n; i++) 
    {
        cin >> w[i]; edges[i].clear();
    }
    for(int i = 1; i < n; i++)
    {
        int u, v; cin >> u >> v;
        edges[v].push_back(u);
        edges[u].push_back(v);
    }
}

int main()
{
    int T; cin >> T;
    while(T--)
    {
        solve();
    }
    return 0;
}